package com.hotelvp.tonight.exception;

import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.os.Build;
import android.os.Build.VERSION;
import android.os.Handler;
import android.os.HandlerThread;
//import com.hotelvp.tonight.App;
import java.util.Calendar;

public class GlobalExceptionHandler
{
  public static String TAG = "com.hotelvp.tonight.GlobalExceptionHandler";
  private static Handler handler;
  private static HandlerThread localHandlerThread;

  public static void register(Context paramContext)
  {
    register(paramContext, paramContext.getClass().getName());
  }

  public static void register(Context paramContext, String paramString)
  {
    PackageManager localPackageManager = paramContext.getPackageManager();
    GlobalExceptionInfo localGlobalExceptionInfo = new GlobalExceptionInfo();
    try
    {
      PackageInfo localPackageInfo = localPackageManager.getPackageInfo(paramContext.getPackageName(), 0);
      localGlobalExceptionInfo.appVersion = localPackageInfo.versionName;
      localGlobalExceptionInfo.appName = localPackageInfo.packageName;
      localGlobalExceptionInfo.phoneModel = Build.MODEL;
      localGlobalExceptionInfo.phone_plateform_Version = Build.VERSION.RELEASE;
//      localGlobalExceptionInfo.imei = App.instance().getIMEI();
      localGlobalExceptionInfo.date_time = Calendar.getInstance().getTimeInMillis();
      localHandlerThread = new HandlerThread(paramString);
      localHandlerThread.start();
      handler = new Handler(localHandlerThread.getLooper());
      Thread.setDefaultUncaughtExceptionHandler(new DefaultExceptionHandler(localGlobalExceptionInfo, paramContext));
      return;
    }
    catch (PackageManager.NameNotFoundException localNameNotFoundException)
    {
      while (true)
        localNameNotFoundException.printStackTrace();
    }
  }
}